
/*
 * Copyright 2002-2018 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2018原作者。
 *
 *根据Apache许可证2.0版（“许可证”）许可；
 *除非符合许可证的规定，否则您不得使用此文件。
 *您可以在以下网址获取许可证副本
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，否则软件
 *根据许可证分发是在“按原样”的基础上分发的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限的特定语言，请参阅许可证
 *许可证下的限制。
 */

package org.springframework.format;

import java.lang.annotation.Annotation;

import org.springframework.core.convert.converter.ConverterRegistry;

/**
 * A registry of field formatting logic.
 *
 * @author Keith Donald
 * @author Juergen Hoeller
 * @since 3.0
 */
/**
 *字段格式化逻辑的注册表。
 *
 *@作者Keith Donald
 *@作者Juergen Hoeller
 *@自3.0起
 */
public interface FormatterRegistry extends ConverterRegistry {

	/**
	 * Adds a Printer to print fields of a specific type.
	 * The field type is implied by the parameterized Printer instance.
	 * @param printer the printer to add
	 * @since 5.2
	 * @see #addFormatter(Formatter)
	 */
	/**
	 *添加打印机以打印特定类型的字段。
	 *参数化的Printer实例隐含了字段类型。
	 *@param printer要添加的打印机
	 *@自5.2起
	 *@见#addFormatter（格式化程序）
	 */
	void addPrinter(Printer<?> printer);

	/**
	 * Adds a Parser to parse fields of a specific type.
	 * The field type is implied by the parameterized Parser instance.
	 * @param parser the parser to add
	 * @since 5.2
	 * @see #addFormatter(Formatter)
	 */
	/**
	 *添加一个Parser来解析特定类型的字段。
	 *参数化的Parser实例隐含了字段类型。
	 *@param parser要添加的解析器
	 *@自5.2起
	 *@见#addFormatter（格式化程序）
	 */
	void addParser(Parser<?> parser);

	/**
	 * Adds a Formatter to format fields of a specific type.
	 * The field type is implied by the parameterized Formatter instance.
	 * @param formatter the formatter to add
	 * @since 3.1
	 * @see #addFormatterForFieldType(Class, Formatter)
	 */
	/**
	 *为特定类型的字段添加格式化程序。
	 *参数化的Formatter实例隐含了字段类型。
	 *@param formatter要添加的格式化程序
	 *@自3.1起
	 *@参见#addFormatterForFieldType（类，格式化程序）
	 */
	void addFormatter(Formatter<?> formatter);

	/**
	 * Adds a Formatter to format fields of the given type.
	 * <p>On print, if the Formatter's type T is declared and {@code fieldType} is not assignable to T,
	 * a coercion to T will be attempted before delegating to {@code formatter} to print a field value.
	 * On parse, if the parsed object returned by {@code formatter} is not assignable to the runtime field type,
	 * a coercion to the field type will be attempted before returning the parsed field value.
	 * @param fieldType the field type to format
	 * @param formatter the formatter to add
	 */
	/**
	 *将格式化程序添加到给定类型的格式化字段中。
	 *<p>在打印时，如果Formatter的类型T被声明，并且{@code fieldType}不可分配给T，
	 *在委托给{@code formatter}打印字段值之前，将尝试强制T。
	 *在解析时，如果{@code formatter}返回的解析对象不可分配给运行时字段类型，
	 *在返回解析的字段值之前，将尝试强制字段类型。
	 *@param field键入要格式化的字段类型
	 *@param formatter要添加的格式化程序
	 */
	void addFormatterForFieldType(Class<?> fieldType, Formatter<?> formatter);

	/**
	 * Adds a Printer/Parser pair to format fields of a specific type.
	 * The formatter will delegate to the specified {@code printer} for printing
	 * and the specified {@code parser} for parsing.
	 * <p>On print, if the Printer's type T is declared and {@code fieldType} is not assignable to T,
	 * a coercion to T will be attempted before delegating to {@code printer} to print a field value.
	 * On parse, if the object returned by the Parser is not assignable to the runtime field type,
	 * a coercion to the field type will be attempted before returning the parsed field value.
	 * @param fieldType the field type to format
	 * @param printer the printing part of the formatter
	 * @param parser the parsing part of the formatter
	 */
	/**
	 *将打印机/分析器对添加到特定类型的格式化字段中。
	 *格式化程序将委托指定的{@code打印机}进行打印
	 *和指定的{@code解析器}进行解析。
	 *<p>在打印时，如果打印机的类型T被声明，并且{@code fieldType}不可分配给T，
	 *在委托{@code printer}打印字段值之前，将尝试强制T。
	 *在解析时，如果解析器返回的对象不可分配给运行时字段类型，
	 *在返回解析的字段值之前，将尝试强制字段类型。
	 *@param field键入要格式化的字段类型
	 *@param printer格式化程序的打印部分
	 *@param parser格式化程序的解析部分
	 */
	void addFormatterForFieldType(Class<?> fieldType, Printer<?> printer, Parser<?> parser);

	/**
	 * Adds a Formatter to format fields annotated with a specific format annotation.
	 * @param annotationFormatterFactory the annotation formatter factory to add
	 */
	/**
	 *将格式化程序添加到使用特定格式注释进行注释的格式字段中。
	 *@param annotationFormatterFactory要添加的注释格式化程序工厂
	 */
	void addFormatterForFieldAnnotation(AnnotationFormatterFactory<? extends Annotation> annotationFormatterFactory);

}
